Connect Kube gateway part 4: frontend#29376
Conversation
|
Note that this change does not include migrating from old tsh kube terminal to new terminal. And since my first time doing these change, not sure how much testing/story I should add. @ravicious @gzdunek one usage thing, when the kube terminal is open, there is no indication of what user should do. |
| case 'success': { | ||
| return <DocumentTerminal doc={doc} visible={visible} />; | ||
| } | ||
|
|
||
| case 'error': { | ||
| return ( | ||
| <Reconnect | ||
| kubeId={params.kubeId} | ||
| statusText={connectAttempt.statusText} | ||
| reconnect={createGateway} | ||
| /> | ||
| ); | ||
| } |
There was a problem hiding this comment.
not sure how these look. happy to improve them if anyone has ideas.
|
I won't have the time to review this today, but I still wanted to offer some help.
We should be able to do it. We used to execute arbitrary commands by writing to the PTY which was not the best idea. But, instead of writing to PTY, we can make Xterm.js think that the PTY emitted some data, even though it's just us and not the actual PTY. This works: diff --git a/web/packages/teleterm/src/sharedProcess/ptyHost/ptyProcess.ts b/web/packages/teleterm/src/sharedProcess/ptyHost/ptyProcess.ts
index 9814d52ff5..5cf443234f 100644
--- a/web/packages/teleterm/src/sharedProcess/ptyHost/ptyProcess.ts
+++ b/web/packages/teleterm/src/sharedProcess/ptyHost/ptyProcess.ts
@@ -76,6 +76,11 @@ export class PtyProcess extends EventEmitter implements IPtyProcess {
this._setStatus('open');
this.emit(TermEventEnum.Open);
+ this.emit(
+ TermEventEnum.Data,
+ 'hey hello \r\nsome fake data is being emitted here \r\n'
+ );
+
this._process.onData(data => this._handleData(data));
this._process.onExit(ev => this._handleExit(ev));
}And since we emit before we add the Look how The message could be even the same as |
…/26836_connect_kube_gateway_go_part_41
ravicious
left a comment
There was a problem hiding this comment.
I reviewed as much as I could today, I'll continue the review tomorrow.
| rootClusterId: string; | ||
| leafClusterId: string | undefined; |
There was a problem hiding this comment.
You don't need these two fields for this document type AFAIK.
There was a problem hiding this comment.
I got an error here when removing these 😭
teleport/web/packages/teleterm/src/ui/DocumentTerminal/useDocumentTerminal.ts
Lines 219 to 238 in e444901
There was a problem hiding this comment.
Ah, I forgot about that. 🤦 Let's just add the same comment above them to say they're tech debt, DocumentGatewayCliClient already has a comment like that.
There was a problem hiding this comment.
Could you summarize the next steps regarding the "migration" to the new document kind, based on the discussion we had in one of the previous PRs?
Edit: nvm, I think it's just this? #28312 (comment)
ravicious
left a comment
There was a problem hiding this comment.
I tested it with the old kube tabs and everything works as expected. Overall I really like how this works and I'm glad we didn't run into any unexpected roadblocks, which means we planned everything pretty well.
I also tested this on Windows, no problems there.
The only thing we should add is more deprecation comments, maybe linking to an issue where we describe what the next steps are to move away from the previous implementation of kube tabs, based on the discussion from #28312 (comment). Could you take care of that?
Helper function to open old kube tab
Put this in connectToKube.ts, then restart the app, open console in devtools in Electron and execute the function with the URI of the kube, which you can inspect also in devtools when opening the table with kubes.
window['connectToOldKube'] = async uri => {
const ctx: IAppContext = window['teleterm'];
const rootClusterUri = routing.ensureRootClusterUri(uri);
const documentsService =
ctx.workspacesService.getWorkspaceDocumentService(rootClusterUri);
const kubeDoc = documentsService.createTshKubeDocument({
kubeUri: uri,
origin: 'resource_table',
});
const connection = ctx.connectionTracker.findConnectionByDocument(kubeDoc);
await ctx.workspacesService.setActiveWorkspace(rootClusterUri);
documentsService.add({
...kubeDoc,
kubeConfigRelativePath:
(connection && connection['kubeConfigRelativePath']) ||
kubeDoc.kubeConfigRelativePath,
});
documentsService.open(kubeDoc.uri);
};There was a problem hiding this comment.
The docs need to be updated to mention that running Connect is now required for the KUBECONFIG to work. I suppose it'd be best to do it in a separate PR.
teleport/docs/pages/connect-your-client/teleport-connect.mdx
Lines 92 to 104 in b3d123e
There was a problem hiding this comment.
sounds good. i will do a separate doc change on this. And likely need to hold off merging the doc change until this is released.
| export interface TrackedKubeConnection extends TrackedConnectionBase { | ||
| kind: 'connection.kube'; | ||
| kubeConfigRelativePath: string; | ||
| kubeConfigRelativePath?: string; |
There was a problem hiding this comment.
| kubeConfigRelativePath?: string; | |
| /** | |
| * @deprecated Used only by connections created by doc.terminal_tsh_kube. | |
| */ | |
| kubeConfigRelativePath?: string; |
As far as frontend tests are involved, I think you added an adequate amount of them. The terminal tabs don't really have proper integration tests anyway and I wouldn't expect you to set all of this up. |
|
Thanks @ravicious for amazing review/comments!
I didn't get a chance to try this out. will give a devtools a try later.
I have added some comments for removing the old implementation in 30bb201. I followed the way it's done in go but is there a standard how to mark deprecate in js? Also, most likely I have not covered everything that needs to be deleted later. |
| // | ||
| // The helpMessage is rendered on the terminal UI without being written or | ||
| // read by the underlying PTY. | ||
| helpMessage?: string; |
There was a problem hiding this comment.
In the other place we have initMessage, I'd use it everywhere.
| }); | ||
|
|
||
| export const makeGateway = (props: Partial<tsh.Gateway> = {}): tsh.Gateway => ({ | ||
| export const makeDBGateway = ( |
There was a problem hiding this comment.
Nit: I'd call it makeDatabaseGateway (to align with, for example, DatabaseUri).
The comment you left should be enough. There's jsdoc's |
…/26836_connect_kube_gateway_go_part_41

Related PR: